<script>
	export default {
		data() {
			return {
				tabIndex: 0,
				info: {},
				dfk_bs: "0",
				qesk_bs: "0",
				yskws_bs: "0",
				myInfo: {},
				sex:0,
				is_sm:2,
				
				flag:1,
			}
		},
		onShareAppMessage() {
			return {
				title: '发布消息找到那个他/她',
				path: '/pages/index/index?id=' + this.myInfo.me_invite_code,
				imageUrl: "https://seekerxcxoss.yiyankeji.vip/Label/Share_img.png"
			}
		},
		onLoad() {
			var that = this
			if(uni.getStorageSync('member_id')){
				that.getMyInfo();
			}else{
				
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						uni.request({
							url: getApp().globalData.host + '/api/Login/registerOrLogin',
							data: {
								wxcode: loginRes.code
							},
							header: {},
							success: (r) => {
								console.log(r.data.data)
								uni.setStorageSync('member_id', r.data.data.memberid)
								uni.setStorageSync('member_token', r.data.data.membertoken)
								
								uni.request({
									url: getApp().globalData.host + '/api/My/getMyInfo',
									header: {
										memberid: uni.getStorageSync('member_id'),
										membertoken: uni.getStorageSync('member_token'),
									},
									success: (rr) => {
										uni.setStorageSync('info', rr.data.data)
										that.info = uni.getStorageSync('info')
										that.myInfo = uni.getStorageSync('info')
									},
								})
				
								uni.request({
									url: getApp().globalData.host + '/api/Fund/getFundInfo',
									header: {
										memberid: uni.getStorageSync('member_id'),
										membertoken: uni.getStorageSync('member_token'),
									},
									success: (rrr) => {
										uni.setStorageSync('getFundInfo', rrr.data.data)
									},
								})
								
								
								uni.request({
									url: getApp().globalData.host + 'api/Order/getOrderCornerMark',
									method: 'POST',
									header: {
										memberid: uni.getStorageSync('member_id'),
										membertoken: uni.getStorageSync('member_token'),
									},
									success: (r) => {
										that.dfk_bs = r.data.data.dfk_bs
										that.qesk_bs = r.data.data.qesk_bs
										that.yskws_bs = r.data.data.yskws_bs
									},
								})
								
								uni.request({
									url: getApp().globalData.host + '/api/My/getIsRead',
									header: {
										memberid: uni.getStorageSync('member_id'),
										membertoken: uni.getStorageSync('member_token'),
									},
									success: (res) => {
										that.is_sm = res.data.data.is_sm
									},
								})
								
								
							},
						})
					}
				});
					
			}
			
		},
		onShow() {
			var that = this
			var info = uni.getStorageSync('info')
			if(uni.getStorageSync('member_id')){
				that.info = info
				that.getMyInfo();
				
				uni.request({
					url: getApp().globalData.host + 'api/Order/getOrderCornerMark',
					method: 'POST',
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						that.dfk_bs = r.data.data.dfk_bs
						that.qesk_bs = r.data.data.qesk_bs
						that.yskws_bs = r.data.data.yskws_bs
					},
				})
				
				uni.request({
					url: getApp().globalData.host + '/api/My/getIsRead',
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (res) => {
						that.is_sm = res.data.data.is_sm
					},
				})
			}
		},
		methods: {
			getMyInfo() {
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/My/getMyInfo',
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						if(r.data.code==800){
							that.flag = 0;
							uni.showModal({
								content:'抱歉，您的账号被封禁，请联系客服'
							})
						}else{
							that.info = r.data.data
							that.myInfo = r.data.data
							that.sex = that.myInfo.me_sex  
							that.lists_count()
						}
					},
				})
			},
			go2(path){
				if(this.flag==0){
					uni.showModal({
						content:'抱歉，您的账号被封禁，请联系客服'
					})
					return
				}
				if(this.sex==0){
					uni.showToast({
						title: "请选择性别",
						icon: "none"
					})
					setTimeout(function(){
						uni.navigateTo({
							url:'/pages/my/setting/setting'
						})
					},2000)
				}else{
					uni.navigateTo({
						url:path
					})
				}
			},
			empty() {
				uni.showToast({
					title: "暂未开放",
					icon: "none"
				})
			},
			lists_count() {
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/My/getmessagewd',
					data: {
						message_type: 1
					},
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						if(r.data.data){
							var count = r.data.data.wd_num
							console.log(count)
							uni.setTabBarBadge({
								index: 3,
								text: String(count)
							})
						}
					},
				})
			
			},
		}
	}
</script>

<template>
	<view class="h-full overflow-hidden">
		<image src="/static/common/bg.png" mode="widthFix" style="" class="absolute w-full"></image>

		<div class="relative z-10 h-full flex flex-col">
			<div>
				<div class="center pb-25" style="padding-top: 110rpx;">我的</div>
			</div>
			<div class="flex px-30" v-if="flag==1">
				<div class="avatar w-150 h-150 flex-shirnk-0 mr-30" @click="go('/pages/my/setting/setting')">
					<image :src="info.me_img" class="w-full h-full rounded-full" style="width: 140rpx;height: 140rpx;"></image>
				</div>
				<div class="w-full">
					<div class="between">
						<div class="fz34 text-black font-bold" v-if="flag==1">
							{{info.me_nick_name}}
						</div>
						<div class="edit" @click="go('/pages/my/setting/setting')">
							<image src="/static/my/edit.png" mode="widthFix" class="w-40 mr-20"></image>
						</div>
					</div>
					<div class="flex mt-10 mb-40" v-if="flag==1">
						<div class="bg-purple text-white px-20 py-5 fz22 rounded-30 mr-16">
							年龄:{{info.me_age}}
						</div>
						<image v-if="info.me_sex==1" src="/static/my/sex1.png" mode="widthFix" class="w-50"></image>
						<image v-if="info.me_sex==2" src="/static/my/sex2.png" mode="widthFix" class="w-50"></image>
					</div>
				</div>
			</div>
			<div class="list bg-white h-full mt-20" style="overflow: auto;">
				<div class="fz30 text-gray-29 mt-20" style="font-weight: bold;">发布者订单</div>
				<div class="flex flex-wrap  mt-20" >
					<div class="flex flex-col center w-150" @click="go2('/pages/my/wallet/wallet')">
						<image src="/static/my/o1.png" mode="aspectFill" class="w-70 h-70"></image>
						<div class="fz24 text-gray-29 mt-15">我的钱包</div>
					</div>
					<div class="flex flex-col center w-150" @click="go('/pages/my/order/myPublish/myPublish')">
						<image src="/static/my/o2.png" mode="aspectFill" class="w-70 h-70"></image>
						<div class="fz24 text-gray-29 mt-15">我的发布</div>
					</div>
				</div>

				<div class="line mt-40 mb-20"></div>
				
				<div class="fz30 text-gray-29 mt-40" style="font-weight: bold;">线索者订单</div>
				<div class="flex flex-wrap mt-20" >
					<div class="flex flex-col center w-150" @click="go('/pages/my/order/wait/wait?type=1')"
						style="position: relative;">
						<image src="/static/my/o3.png" mode="aspectFill" class="w-70 h-70"></image>
						<div class="fz24 text-gray-29 mt-15">待收款</div>
						<view v-if="dfk_bs!=0"
							style="position: absolute;left: 65%;top: 40%; border-radius: 20px; padding: 2rpx 10rpx; background-color: red; color: white; text-align: center;font-size: 10px;">
							{{dfk_bs}}</view>
					</div>
					<div class="flex flex-col center w-150" @click="go('/pages/my/order/wait/wait?type=2')"
						style="position: relative;">
						<image src="/static/my/o4.png" mode="aspectFill" class="w-70 h-70"></image>
						<div class="fz24 text-gray-29 mt-15">已收款50%</div>
						<view v-if="yskws_bs!=0"
							style="position: absolute;left: 65%;top: 40%; border-radius: 20px;  padding: 2rpx 10rpx; background-color: red; color: white; text-align: center;font-size: 10px;">
							{{yskws_bs}}</view>
			
					</div>
					<div class="flex flex-col center w-150" @click="go('/pages/my/order/wait/wait?type=3')"
						style="position: relative;">
						<image src="/static/my/o5.png" mode="aspectFill" class="w-70 h-70"></image>
						<div class="fz24 text-gray-29 mt-15">全额收款</div>
						<view v-if="qesk_bs!=0"
							style="position: absolute;left: 65%;top: 40%; border-radius: 20px;  padding: 2rpx 10rpx; background-color: red; color: white; text-align: center;font-size: 10px;">
							{{qesk_bs}}</view>
			
					</div>
				</div>
			
				<div class="line mt-40 mb-20"></div>


				<div class="between mt-20" style="position: relative;">
					<button open-type="contact" type="default" class="w-full between" style="border:0;padding:0; background-color: transparent;border: 0px;">
						<div class="flex">
							<image src="/static/my/s1.png" mode="widthFix" class="w-30 h-30"></image>
							<div class="fz30 text-gray-29 ml-18">联系客服</div>
						</div>
						<image src="/static/my/right.png" mode="widthFix" class="w-25 h-25"></image>
					</button>

				</div>

				<div class="line mt-20 mb-20" v-if="is_sm==1"></div>

				<div class="between mt-50" @click="empty()" style="display: none;">
					<div class="flex">
						<image src="/static/my/s2.png" mode="widthFix" class="w-30 h-30"></image>
						<div class="fz30 text-gray-29 ml-18">设置</div>
					</div>
					<image src="/static/my/right.png" mode="widthFix" class="w-25 h-25"></image>
				</div>

				<div class="line mt-40 mb-40" style="display: none;"></div>


				<div class="between mt-40 mb-40" @click="go('/pages/my/auth/auth')" v-if="is_sm==1">
					<div class="flex">
						<image src="/static/my/s3.png" mode="widthFix" class="w-30 h-30"></image>
						<div class="fz30 text-gray-29 ml-18">实名认证</div>
					</div>
					<image src="/static/my/right.png" mode="widthFix" class="w-25 h-25"></image>
				</div>
				<div class="between mt-50" @click="empty()" style="display: none;">
					<div class="flex">
						<image src="/static/my/s4.png" mode="widthFix" class="w-30 h-30"></image>
						<div class="fz30 text-gray-29 ml-18">关于我们</div>
					</div>
					<image src="/static/my/right.png" mode="widthFix" class="w-25 h-25"></image>
				</div>

				<div class="line mt-20 mb-40"></div>


				<div class="between" @click="go('/pages/my/resources/resources')">
					<div class="flex">
						<image src="/static/my/s5.png" mode="widthFix" class="w-30 h-30"></image>
						<div class="fz30 text-gray-29 ml-18">我的资源库</div>
					</div>
					<image src="/static/my/right.png" mode="widthFix" class="w-25 h-25"></image>
				</div>

				<div class="line mt-40 mb-40"></div>


				<div class="between" v-if="flag==1" @click="go('/pages/my/invite/invite')">
					<div class="flex">
						<image src="/static/my/s6.png" mode="widthFix" class="w-30 h-30"></image>
						<div class="fz30 text-gray-29 ml-18">{{myInfo.invite_word}}</div>
					</div>
					<image src="/static/my/right.png" mode="widthFix" class="w-25 h-25"></image>
				</div>

				<div class="line mt-40 mb-40" v-if="flag==1"></div>


			</div>

		</div>
	</view>
</template>



<style lang="less">
	page {
		height: 100%;
	}

	.list {
		border-radius: 29rpx 29rpx 0 0;
		padding: 39rpx 30rpx;
	}
	button:active {
	  outline: none;
	}
	button {
	  box-shadow: none; /* 初始状态下没有阴影 */
	}
	button:focus {
	  outline: none;
	}
	button {
	  -webkit-tap-highlight-color: transparent; /* iOS上点击时的背景高亮 */
	}
	button::after{
		border: none;
	}
</style>